package Eyjafjalla.relic;

import Eyjafjalla.action.*;
import Eyjafjalla.helper.StringHelper;
import Eyjafjalla.patch.MelodyPatch;
import Eyjafjalla.subscriber.MelodySubscriber;
import basemod.abstracts.CustomRelic;
import com.megacrit.cardcrawl.actions.AbstractGameAction;
import com.megacrit.cardcrawl.actions.common.*;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.ImageMaster;
import com.megacrit.cardcrawl.helpers.PowerTip;
import com.megacrit.cardcrawl.relics.AbstractRelic;

import java.util.ArrayList;

public class ShallowSong extends CustomRelic implements MelodySubscriber {

    public static final String ID = "eyjafjalla:ShallowSong";

    public ShallowSong(){
        super(ID, ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,false)),ImageMaster.loadImage(StringHelper.getRelicIMGPATH(ID,true)),RelicTier.RARE,LandingSound.CLINK);
        setCounter(3);
    }

    @Override
    public void atBattleStartPreDraw() {
        this.flash();
        this.addToBot(new RelicAboveCreatureAction(AbstractDungeon.player, this));
        this.addToBot(new MelodyAction(getSingle()));
    }

    @Override
    public void setCounter(int counter) {
        this.counter = counter;
        description = getUpdatedDescription();
        this.tips.clear();
        this.tips.add(new PowerTip(this.name, this.description));
        this.initializeTips();
    }

    @Override
    public MelodyPatch.MelodySingle getSingle(){
        ArrayList<MelodyPatch.MelodyNote> notes = new ArrayList<>();
        notes.add(new MelodyPatch.MelodyNote(this,0,2,DESCRIPTIONS[2]+this.counter+DESCRIPTIONS[3]));
        notes.add(new MelodyPatch.MelodyNote(this,1,1,DESCRIPTIONS[2]+this.counter+DESCRIPTIONS[3]));
        notes.add(new MelodyPatch.MelodyNote(this,2,3,DESCRIPTIONS[2]+this.counter+DESCRIPTIONS[3]));

        MelodyPatch.MelodyNote finalNote = new MelodyPatch.MelodyNote(this,-1,4,DESCRIPTIONS[4]);
        MelodyPatch.MelodySingle single = new MelodyPatch.MelodySingle(this.name,notes,finalNote);
        return single;
    }

    @Override
    public ArrayList<AbstractGameAction> getNoteActions(boolean isFinal, int specialAmount) {
        ArrayList<AbstractGameAction> actions = new ArrayList<>();
        if(isFinal){
            actions.add(new ShallowSongAction(this));
        }
        else {
            actions.add(new ShallowLoseAction(specialAmount));
        }
        return actions;
    }

    @Override
    public int initializeSpecialAmount(boolean isFinal) {
        return this.counter;
    }

    @Override
    public String getUpdatedDescription() {
        return DESCRIPTIONS[0]+this.counter+DESCRIPTIONS[1];
    }

    @Override
    public AbstractRelic makeCopy() {
        return new ShallowSong();
    }
}



